home *** CD-ROM | disk | FTP | other *** search
- Path: news.packet.net!usenet
- From: mrivers@tbag.org (Michael Rivers)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Listview Problem
- Date: Mon, 1 Jan 96 02:19:58 EST
- Organization: TBAG
- Distribution: world
- Message-ID: <19960101.3BC8A8.2C05@tbag.org>
- NNTP-Posting-Host: tbag.org
-
- JL> I am trying to make a listview gadget. I have followed the RKM's as
- JL> close as possible. I am able to get the listview to show up on my
- JL> window, but the text that goes in the listview is not there. I have
- JL> made
- JL> a node list and named each one. The slider knob is the right size for
- JL> the number of nodes in the list. What am I missing...
-
- JL> This is a repeat post because I think I removed the last one. In the
- JL> previous post, someone replied to put source code up. here goes:
-
- After building the List & Nodes you need to:
- **************************************************************
- GT_SetGadgetAttrs(lvgadget,xwindow,0,GTLV_Labels,namelist,TAG_DONE);
- **************************************************************
-
- JL> void makelabels(void)
- JL> {
- JL> size_t q;
- JL> char x;
-
- JL> xtype = 0;
- JL> xfp = (FILE *)fopen("Xenolink:users/Userfile.xlk","rb+");
- JL> fseek(xfp, sizeof(struct User), SEEK_SET);
-
- JL> namelist = (struct List *)AllocVec(sizeof(struct MinList),
- ^^^^^^^^^*1^^^^^^^^^^^
- JL> MEMF_CLEAR|MEMF_CHIP);
- ^^^^^^^^^^
-
- This is wrong. should be AllocVec(sizeof(struct List)...(see *2 below)
- Also, you should remove the MEMF_CHIP flags. It may need the MEMF_PUBLIC
- flag, however, I am not sure.
-
- JL> if(!namelist)
- JL> {
- JL> printf("Error: Allocating Memory for List!\n");
- JL> exit(0);
- JL> }
- JL> else
- JL> {
- JL> namelist->lh_Type=32;
- ^^^^^^^*2^^^^^^^^^^^^
- This is a no-no. (see *1) You've allocated only enough mem for a MinList,
- however your using it as a List, and you accessing ram you don't own.
-
- JL> NewList((struct List *)namelist);
- ^^^^^^^^^^^^^^^ not neccessary.
- JL> }
-
- /* below here is a replacement for your do/while loop.*/
-
- ...
-
- while(q = fread(&xuser, sizeof(struct User), 1L, xfp));
- {
- if(q==sizeof(struct User))
- {
- if(namenode=AllocNamedNode(xuser.Name)) /* See below */
- {
- namenode->ln_Type = 100;
- AddTail((struct List *)namelist, (struct Node *)namenode);
- }
- else
- {
- /* do error handling stuff here */
- }
- }
- }
-
- ...
-
-
- /*---Be sure to make a prototype-------*/
-
- struct Node *AllocNamedNode(STRPTR Name)
- {
- struct Node *n;
-
- if(n=AllocVec(sizeof(struct Node),MEMF_CLEAR|MEMF_PUBLIC))
- {
- if(n->ln_Name=AllocVec(strlen(Name)+1,MEMF_CLEAR|MEMF_PUBLIC))
- {
- strcpy(n->ln_Name,Name);
- return(n)
- }
- FreeVec(n)
- }
- return(0);
- }
-
-
- ╖---------------------------------------------------------╖
- | Commodore failure. Press left mouse button to continue |
- | Error: $0100000C Task : $416C6920 |
- ╖---------------------------------------------------------╖
- Mike Rivers (aka) Vermin -- mrivers@tbag.tscs.com
- A4000/040 25mhz 18megs 1,451meg hd
-
- ... Windows, If swallowed, do not induced vomiting.
- * Q-Blue 2.0 [NR] *
-